package com.blog.wl2023.repository;

import com.blog.wl2023.entity.Announcement;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author wule
 * @desc
 */
@Repository
public interface AnnouncementRepository extends JpaRepository<Announcement, Long>,JpaSpecificationExecutor<Announcement> {

	@Query("select a from Announcement a where a.status= '1'")
	List<Announcement> getAnnouncementIsShow();

	@Modifying
	@Transactional
	@Query("update Announcement a set a.status=:status where a.uuid = :uuid")
	void handoffShowAnnouncement(String uuid, String status);
}
